package com.gxa.community.admin.service.classification.impl;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.gxa.community.admin.mapper.classification.ClassificationMapper;
import com.gxa.community.admin.service.classification.ClassificationService;
import com.gxa.community.core.pojo.dto.classification.ClassificationDTO;
import com.gxa.community.core.utils.R;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Slf4j
@Service
public class ClassificationImpl implements ClassificationService {
    @Autowired
    private ClassificationMapper classificationMapper;

    @Override
    public String queryAllClassificationAndAllGoodsInfo() throws JsonProcessingException {
        List<ClassificationDTO> classificationDTOS = classificationMapper.selectAllClassification();
        R result = R.ok("查询成功！").put("allClassification", classificationDTOS);
        ObjectMapper objectMapper = new ObjectMapper();
        String r = objectMapper.writeValueAsString(result);
        return r;
    }
}
